package com.sptokentest.controller;


import cn.dev33.satoken.util.SaResult;
import com.sptokentest.pj.dto.UserRoleDto;
import com.sptokentest.entity.User;
import com.sptokentest.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author young
 * @since 2023年02月03日
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/page")
    public SaResult userAdmin(int page,int pageSize,String username){
       return userService.getPages(page,pageSize,username);
    }

    @PostMapping("/status")
    public SaResult status(@RequestBody User user){
        return userService.status(user);
    }

    @DeleteMapping("{id}")
    public SaResult delete(@PathVariable Long id){
        return userService.delete(id);
    }

    @PostMapping
    public SaResult add(@RequestBody UserRoleDto user){
        return userService.addUser(user);
    }

    @PutMapping
    public SaResult edit(@RequestBody UserRoleDto user){
        return userService.editUser(user);
    }
//    @GetMapping("/")
//    public SaResult getUserById(){
//
//    }
}

